home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
text
/
misc
/
ht.lha
/
hypertext
/
Rexx
/
setup.dme
< prev
next >
Wrap
Text File
|
1990-12-23
|
6KB
|
274 lines
/* This program will let a user specify various setup options for an HT
* document from within their text editor.
*/
/****************
* D.B.G. 1990
****************/
/* should check for failure of these calls */
if ~Show('L', 'rexxsupport.library') then
check = AddLib('rexxsupport.library', 10, -30, 0)
if (check == 0) then do
say "Need to have the rexxsupport library in LIBS:!"
exit
end
if ~Show('L', 'rexxarplib.library') then
check = AddLib('rexxarplib.library', 10, -30, 0)
if (check == 0) then do
say "Need to have the rexxarplib.library and screenshare.library in LIBS:"
exit
end
/* this variable and its stems define the gadget names and the
* associated file name. Change them to suit your system.
*/
cport = 'SETUP_PORT'
notport = 'SETUP_notify'
address AREXX "'x=call CreateHost(" cport "," notport ")'"
do until ShowList(P,cport)
call Delay(10)
end
idcmp = 'CLOSEWINDOW+WINDOWDRAG+GADGETUP'
flags = 'WINDOWCLOSE+WINDOWDRAG+BACKFILL'
call OpenWindow(cport, 100, 20, 450, 130, idcmp, flags, 'Setup Requestor')
call ActivateWindow(cport)
call SetDrMd(cport, COMPLEMENT)
call Move(cport, 20, 20)
call Text(cport, "Help Filename : ")
call AddGadget(cport, 155, 14, "Help", "", "help = '%g'", 250)
call Move(cport, 20, 40)
call Text(cport, "Window Title : ")
call AddGadget(cport, 155, 34, "Title", "", "title = '%g'", 250)
call Move(cport, 20, 60)
call Text(cport, "Font Name : ")
call AddGadget(cport, 115, 54, "Font", "", "font = '%g'", 130)
call Move(cport, 295, 60)
call Text(cport, "Size : ")
call AddGadget(cport, 355, 54, "Size", "", "size = '%g'", 50)
call Move(cport, 35, 70)
call Draw(cport, 390, 70)
/* FIXME : the following code is very brain dead and should be in some
* sort of a loop or function call.
*/
/* do the foreground color gadgets */
call Move(cport, 20, 80)
call Text(cport, "Foreground Color")
call SetDrMd(cport, JAM1)
call AddGadget(cport, 20, 85, "fgcolor0", " ", "fg = 0 ; call highlight_type 20 85")
call SetAPen(cport, 0)
call RectFill(cport, 22, 86, 38, 93)
call AddGadget(cport, 50, 85, "fgcolor1", " ", "fg = 1 ; call highlight_type 50 85")
call SetAPen(cport, 1)
call RectFill(cport, 52, 86, 68, 93)
call AddGadget(cport, 80, 85, "fgcolor2", " ", "fg = 2 ; call highlight_type 80 85")
call SetAPen(cport, 2)
call RectFill(cport, 82, 86, 98, 93)
call AddGadget(cport, 110, 85, "fgcolor3", " ", "fg = 3 ; call highlight_type 110 85")
call SetAPen(cport, 3)
call RectFill(cport, 112, 86, 128, 93)
/* now do the background colors */
call Move(cport, 280, 80)
call Text(cport, "Background Color")
call SetDrMd(cport, JAM1)
call AddGadget(cport, 290, 85, "bgcolor0", " ", "bg = 0 ; call highlight_type 290 85")
call SetAPen(cport, 0)
call RectFill(cport, 292, 86, 308, 93)
call AddGadget(cport, 320, 85, "bgcolor1", " ", "bg = 1 ; call highlight_type 320 85")
call SetAPen(cport, 1)
call RectFill(cport, 322, 86, 338, 93)
call AddGadget(cport, 350, 85, "bgcolor2", " ", "bg = 2 ; call highlight_type 350 85")
call SetAPen(cport, 2)
call RectFill(cport, 352, 86, 368, 93)
call AddGadget(cport, 380, 85, "bgcolor3", " ", "bg = 3 ; call highlight_type 380 85")
call SetAPen(cport, 3)
call RectFill(cport, 382, 86, 398, 93)
/* o.k. and cancel gadgets */
call AddGadget(cport, 20, 110, "ok", " O.K. ", "ok")
call AddGadget(cport, 340, 110, "cancel", " Cancel ", "cancel")
mainport = 'SP'
mport = OpenPort(mainport)
do until ShowList(P, mainport)
call delay(10)
end
call SetNotify(cport, GADGETUP, mainport)
call SetNotify(cport, CLOSEWINDOW, mainport)
notquit = 1
/* main event loop */
do while notquit
call WaitPkt(mainport)
packet = GetPkt(mainport)
if packet ~== '0000 0000'x then
do
id = GetArg(packet, 0)
call Reply(packet, 0)
if (word(id, 1) = "fg" | word(id, 1) = "bg") then do
if (word(id, 1) = "bg") then
i = 290
else
i = 20
call SetAPen(cport, 1)
call RectFill(cport, i, 98, i+150, 105)
call SetAPen(cport, 3)
end
select
when id = 'CLOSEWINDOW' then call closeup()
when id = 'cancel' then call closeup()
when id = 'ok' then call goodbye()
otherwise interpret id
end
end
end
exit
/* this function will exit cleanly from this program */
closeup:
call stop("SETUP_PORT")
exit
return
/* this should insert the appropriate text */
goodbye:
'ping 9' /* set current position */
'top' /* move to beginning of buffer */
'first'
help = ""
string = get_gadg_string("HELP")
interpret string
if help ~= "" then do
'insline'
'('"\\\help " help')'
'first'
end
title = ""
string = get_gadg_string("TITLE")
interpret string
if title ~= "" then do
'insline'
'('"\\\title "title ')'
'first'
end
font = ""
string = get_gadg_string("FONT")
interpret string
size = ""
string = get_gadg_string("SIZE")
interpret string
if font ~= "" & size ~= "" & datatype(size, NUM) then do
'insline'
'('"\\\font" font size ')'
'first'
end
if fg ~= "FG" then do
'insline'
'('"\\\fgcolor "fg ')'
'first'
end
if bg ~= "BG" then do
'insline'
'('"\\\bgcolor "bg ')'
'first'
end
'pong 9'
call closeup()
return
/* this function puts a little triangle beneath a boolean gadget to indicate
* that it is highlighted.
*/
highlight_type:
arg x y
y = y - 1
call AreaMove(cport, x+5, y+20)
call AreaDraw(cport, x+15, y+20)
call AreaDraw(cport, x+10, y+15)
call AreaDraw(cport, x+5, y+20)
call AreaEnd(cport)
drop x y
return
do_filerequest:
res = GetFile(15, 10, "", "", "Select name of file use:")
cur_name = get_gadg_string()
/* if true, we have to extract relevant info and keep it */
if cur_name ~= "" then do
parse var cur_name . stuff
res = res || stuff
end
gadg.9.name = res
call RemoveGadget(cport, "gadg9")
call AddGadget(cport, 25, 105, "gadg9", gadg.9.name, "%g", 250)
call RefreshGadgets(cport)
call ActivateGadget(cport, "gadg9")
drop res cur_name
return
/* returns the string contained in the string gadget. This routine
* should be generalized more
*/
get_gadg_string:
arg gadget_name
options results
call ReadGadget(cport, gadget_name)
call WaitPkt(mainport)
packet = GetPkt(mainport)
ret = GetArg(packet, 0)
call Reply(packet, 0)
return ret